package com.xiaoma.tpo.dao;

import com.xiaoma.tpo.baseDao.BaseDaoImpl;
import com.xiaoma.tpo.baseDao.DefaultRowMapper;
import com.xiaoma.tpo.domain.ClsGateSentence;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by Owner on 2015/5/21.
 */
@Repository
public class ClsGateSentenceDao extends BaseDaoImpl<ClsGateSentence>{
    private static final Logger LOG = LoggerFactory.getLogger(ClsSentenceDao.class);

    @SuppressWarnings("unchecked")
    public List<ClsGateSentence> findGateSentenceByGateId(int gateId){
        String sql = "select b.*,a.code code,a.sentence sentence,a.sentence_cn sentence_cn,a.audio_code audio_code from cls_sentence a, cls_gate_sentence b where a.id = b.cls_sentence_id and b.cls_gate_id = ?";
        LOG.info("SQL:{} gateId:{}", sql, gateId);
        List<?> result = jdbcTemplate.query(sql, new DefaultRowMapper(ClsGateSentence.class, getNameHandler()),gateId);
        return (List<ClsGateSentence>)result;
    }
}
